package src.lab03.test04;

import java.io.*;;

/**
 * Created by 12442 on 2017/12/13.
 */
public class Test {
    private static Test FileFunction;

    public static void main(String[] args) throws FileNotFoundException {
        String fromFileName = "D:\\source\\High.mp3";
        fromFileName = "D:\\target";
        String toFileName = "D:\\copy\\source\\High.mp3";
        FileFunction.copyFile(fromFileName,toFileName);
    }
    public static void copyFile(String fromFileName, String toFileName) throws FileNotFoundException {
        InputStream in = new FileInputStream(fromFileName);
        OutputStream out = new FileOutputStream(toFileName);
        int len;
        try {
            while ((len = in.read()) != -1) {
                out.write(len);
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
        System.out.println("文件拷贝成功");
        try {
            in.close();
            out.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
